package com.lhf.enumfile;

/**
 * @author 尐痞猫
 * @date2021-07-05 16:57
 */
public enum Currency {
    RENMINBI(1,"人民币"),
    MEIYUAN(2,"美元"),
    RIYUAN(3,"日元"),
    OUYUAN(4,"欧元"),
    JIAYUAN(5,"加元"),
    AOYUAN(6,"欧元"),
    GANGYUAN(7,"港元");

    private Integer currencyCode;
    private String currencyName;

    //必须有一个构造方法
    Currency(Integer currencyCode,String currencyName) {
        this.currencyCode=currencyCode;
        this.currencyName=currencyName;
    }
    public String getCurrencyName() {
        return currencyName;
    }

    public Integer getCurrencyCode() {
        return currencyCode;
    }

    public static String getCurrencyName(Integer currencyCode){
        for (Currency c : Currency.values()) {
            if (currencyCode==c.getCurrencyCode()){
                return c.getCurrencyName();
            }
        }
        return null;
    }

}
